/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package galnaat.szofttech;

import java.util.Random;

/**
 *
 * @author lazly
 */
public class player {
    public enum classes {
        GUARD, WARRIOR, HERO
    }
    private static classes cclass;
    private static String cname;
    private static int te, ve;
    private int hp, xp, level;
    private boolean active, alive;

    private static final int delta = 10;
    Random generator = new Random();

    public player (String tname, String tclasses) {
        active = false;
        if ("GUARD".equals(tclasses)) {
            cclass = classes.GUARD;
            te = 40 + generator.nextInt( delta ) - delta / 2;
            ve = 60 + generator.nextInt( delta ) - delta / 2;
            active = true;
        }
        if ("WARRIOR".equals(tclasses)) {
            cclass = classes.WARRIOR;
            te = 50 + generator.nextInt( delta ) - delta / 2;
            ve = 50 + generator.nextInt( delta ) - delta / 2;
            active = true;
        }
        if ("HERO".equals(tclasses)) {
            cclass = classes.HERO;
            te = 60 + generator.nextInt( delta ) - delta / 2;
            ve = 40 + generator.nextInt( delta ) - delta / 2;
            active = true;
        }
        cname = tname;
        hp = 50 + generator.nextInt( delta ) - delta / 2;
        xp = 0;
        level = 1;
        alive = true;
    }
    
    public String cclass() { return cclass.toString(); }
    public String cname() { return cname; }
    public int hp() { return hp; }
    public int te() { return te; }
    public int ve() { return ve; }
    public int xp() { return xp; }
    public int level() { return level; }
    public boolean alive() { return alive; }
    
    public void blood(int i) {
    	if (active && i > 0) {
    		hp -= i;
    		if (hp <= 0) {
    			alive = false;
    		}
    	}
    }
    
    public void experience(int i) {
    	if (active && i > 0) {
    		xp += i;
    		if (xp >= 100) {
    			// Szintlepes
    			level += 1;
    			hp += 20 - generator.nextInt( delta ) - delta / 2;
    			te += 10 - generator.nextInt( delta ) - delta / 2;
    			ve += 10 - generator.nextInt( delta ) - delta / 2;
    			xp -= 100;
    		}
    	}
    }

}